
#include "common.fxh"

cbuffer cbPerObject
{
	float4x4 gWVP;
	float4 gDiffMat;
};

cbuffer cbPerFrame
{
	float3 gAmbLight;
};


Texture2D gDiffuseMap;

SamplerState gTriLinearSam
{
	Filter = MIN_MAG_MIP_LINEAR;
	AddressU = Wrap;
	AddressV = Wrap;
};

struct VS_IN
{
	float3 posL     : POSITION;
	float3 tangentL : TANGENT;
	float3 normalL  : NORMAL;
	float2 texC     : TEXCOORD;
};

struct VS_OUT
{
	float4 posH         : SV_POSITION;
    float2 texC         : TEXCOORD2;
};

VS_OUT VS(VS_IN vIn)
{
	VS_OUT vOut;
	
	vOut.posH = mul(float4(vIn.posL, 1.0f), gWVP);
	vOut.texC = vIn.texC;
	
	return vOut;
}


float4 PS(VS_OUT pIn) : SV_Target
{      
	float3 ambient = gDiffMat * gAmbLight;
	return float4( ambient * gDiffuseMap.Sample(gTriLinearSam, pIn.texC), 1.0f);
}

DepthStencilState DepthOnState
{
    DepthEnable = TRUE;
};

technique10 tech
{
    pass P0
    {
        SetVertexShader( CompileShader( vs_4_0, VS() ) );
        SetGeometryShader( NULL );
        SetPixelShader( CompileShader( ps_4_0, PS() ) );
		//SetDepthStencilState(DepthOnState, 0);
    }
}
